import Cookies from 'js-cookie'
import { encryptData } from '@/utils/openssl'
const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token, expiredAt) {
  var options = Object.assign(
    {
      sameSite: 'strict'
    },
    expiredAt && {
      expires: new Date(expiredAt * 1000)
    }
  )
  return Cookies.set(TokenKey, token, options)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function getAccessToken() {
  return encryptData(getToken())
}
